﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>设置文本框的背景颜色</title>
</head>
<script language="javascript">
    function txtfocus(event) {
        var e = window.event;
        var obj = e.srcElement;
        obj.style.background = "#F00066";
    }
    function txtblur(event) {
        var e = window.event;
        var obj = e.srcElement;
        obj.style.background = "FFFFF0";
    }
</script>
<body>
    <table align="center" width="360" height="228" border="0">
        <tr>
            <td width="188">登录名:</td>
            <td width="226">
                <form name="form1" method="post" action="">
                    <input type="text" name="textfield" onfocus="txtfocus()" onblur="txtblur()">
                </form>
            </td>
        </tr>
        <tr>
            <td>密码:</td>
            <td>
                <form name="form2" method="post" action="">
                    <input type="text" name="textfield2" onfocus="txtfocus()" onblur="txtblur()">
                </form>
            </td>
        </tr>
        <tr>
            <td>姓名:</td>
            <td>
                <form name="form3" method="post" action="">
                    <input type="text" name="textfield3" onfocus="txtfocus()" onblur="txtblur()">
                </form>
            </td>
        </tr>
        <tr>
            <td>性别:</td>
            <td>
                <form name="form4" method="post" action="">
                    <input type="text" name="textfield5" onfocus="txtfocus()" onblur="txtblur()">
                </form>
            </td>
        </tr>
        <tr>
            <td>联系方式：</td>
            <td>
                <form name="form5" method="post" action="">
                    <input type="text" name="textfield4" onfocus="txtfocus()" onblur="txtblur()">
                </form>
            </td>
        </tr>
    </table>
</body>
</html>